from flask import request, jsonify
from frame.util.PlaywrightUtil import PlaywrightUtil  # 导入计算逻辑函数
from frame.exception.ApiException import ApiException


class Index:
    # 获取html内容
    def get_html_conntent(self, url, wait_time):
        # content = get_web_text('https://www.xsframe.cn')

        target_url = request.args.get('url')
        wait_time = request.args.get('time')

        # app.logger.error('This is an error message')

        if not target_url:
            raise ApiException(msg='URL is required')

        crawler = PlaywrightUtil()

        content = crawler.scrape(target_url, wait_time)
        return content
